PrimeFaces.widget.SelectManyCheckbox.prototype.checkAll = function() {
	this.inputs.prop('checked', true);
	this.outputs.addClass('ui-state-active');
	this.outputs.find('span').addClass('ui-icon ui-icon-check ui-state-active');
};

PrimeFaces.widget.SelectManyCheckbox.prototype.uncheckAll = function() {
	this.inputs.prop('checked', false);
	this.outputs.removeClass('ui-state-active');
	this.outputs.find('span').removeClass('ui-icon ui-icon-check ui-state-active');
};

function toggle($self, $target) {
	if ($self.is(':checked')) {
		$target.checkAll();
	} else {
		$target.uncheckAll();
	}
}